from typing import List


class Solution:


    def minSubArrayLen(self, target: int, nums: List[int]) -> int:
        # 要求连续的，那就使用双指针
        slow = 0
        fast = 0
        size = len(nums)
        result = 0
        ret_min = float('inf')
        while fast < size:
            result += nums[fast]
            while result >= target:
                ret_min = min(ret_min, fast - slow + 1)
                result -= nums[slow]
                slow+=1

            fast += 1
        return ret_min
s = 7
# nums = [2,3,1,2,4,3]
nums = [2,3,1,2,4,3]
print(Solution().minSubArrayLen(s,nums))